<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function(Blueprint $table)
        {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户id');
            $table->string('order_num')->nullable()->comment('订单编号');
            $table->integer('books_id')->default(0)->comment('书本或章节id');
            $table->integer('recharge_package_id')->default(0)->comment('阅读币套餐id');
            $table->decimal('unit_price',11,2)->default(0)->comment('单价金额');
            $table->integer('unit_books_coin')->default(0)->comment('单价阅读币');
            $table->integer('num')->default(0)->comment('商品总量');
            $table->decimal('amount_money',11,2)->default(0)->comment('总金额');
            $table->integer('amount_books_coin')->default(0)->comment('总阅读币数');
            $table->string('remark')->nullable()->comment('备注');
            $table->string('type')->nullable()->comment('订单类型  book整本书/books_coin阅读币/vip会员购买/book_chapter一章节/company_payment提现');
            $table->tinyInteger('is_pay')->default(0)->comment('是否已支付，0：未支付，1：已支付');
            $table->timestamp('pay_time')->nullable()->comment('支付时间');
            $table->string('pay_type')->nullable()->comment('支付方式：wechat/alipay/pos/books_coin');
            $table->tinyInteger('status')->default(0)->comment('状态 0：未完成 1：已完成');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
